import 'package:flutter/material.dart';

class TxtApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return new MaterialApp(
      title: 'ok',
      theme: new ThemeData(primaryColor: Colors.blue),
      home: new ChangeTxtWidget(),
    );
  }
}

class ChangeTxtWidget extends StatefulWidget {
  @override
  State<StatefulWidget> createState() {
    return new ChangeTxtState();
  }
}

class ChangeTxtState extends State<ChangeTxtWidget> {
  String txt = 'txt prechanged';

  void change() {
    setState(() {
      txt = 'txt after changed';
    });
  }

  @override
  Widget build(BuildContext context) {
    return new Scaffold(
      appBar: new AppBar(
        title: new Text('appbar'),
      ),
      body: new Center(
        child: new Text(txt),
      ),
      floatingActionButton: new FloatingActionButton(
        onPressed: change,
        tooltip: 'update txt',
        child: new Icon(Icons.add),
      ),
    );
  }
}
